package com.tuanzi.loan.business.service.wallet.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tuanzi.loan.business.entity.wallet.LoanUserWallet;
import com.tuanzi.loan.business.repository.wallet.LoanUserWalletRepository;
import com.tuanzi.loan.business.repository.wallet.custom.LoanUserWalletRepositoryCustom;
import com.tuanzi.loan.business.service.wallet.LoanUserWalletService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.service.CommonServiceImpl;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.wallet.LoanUserWalletRequest;
import com.tuanzi.loan.vo.response.wallet.LoanUserWalletResponse;

@Debug
@Service
@Transactional
@Retryable(value = { RetryException.class })
public class LoanUserWalletServiceImpl extends CommonServiceImpl<LoanUserWallet, Long> implements LoanUserWalletService{

	@Autowired
	private LoanUserWalletRepositoryCustom loanUserWalletRepositoryCustom;
	
	@Autowired
	private LoanUserWalletRepository loanUserWalletRepository;
	
	@Override
	public Page<LoanUserWalletResponse> list(
			PageSearcher<LoanUserWalletRequest> pageSearcher) {
		return loanUserWalletRepositoryCustom.list(pageSearcher.getSearchCondition(), pageSearcher.getPageable());
	}

	@Override
	protected JpaRepository<LoanUserWallet, Long> getRepository() {
		return loanUserWalletRepository;
	}

	@Override
	public LoanUserWallet findByUserId(Long userId) {
		return loanUserWalletRepository.findByUserId(userId);
	}

	@Override
	public LoanUserWallet findById(Long id) {
		return loanUserWalletRepository.findById(id);
	}

}
